<template>
  <div>
    <upload-excel :on-success="handleSuccess" :before-upload="beforeUpload">
      <!--  -->
    </upload-excel>
  </div>
</template>

<script>
import { importEmployee } from '@/api/employees'
import { transExcelDataToSouceData } from '@/utils/excelData'
export default {
  methods: {
    beforeUpload(file) {
      console.log(file)
      const size = file.size / 1024
      if (size > 10) {
        this.$message({
          type: 'warning',
          message: '文件不能超过10kb'
        })
        return false
      }
      return true
    },
    async handleSuccess(data) {
      console.log(data)
      await importEmployee(transExcelDataToSouceData(data.results))
      this.$router.back()
    }
  }
}
</script>

<style>

</style>
